/*
package com.lx.chong.aspect;

import com.joriving.pdf.enums.ResultEnum;
import com.joriving.pdf.exception.PdfAuthorizeException;
import com.joriving.pdf.exception.PdfCommonException;
import com.joriving.pdf.service.impl.LoginServiceImpl;
import com.joriving.pdf.utils.PropertiesUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

*/
/**
 * 切面校验类
 * 控制访问权限
 *
 * @author: whh
 * @date: 2018/1/17
 *//*

@Aspect
@Component
@Slf4j
public class PdfAuthorizeAspect {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Autowired
    private LoginServiceImpl loginService;

//    @Pointcut("execution(public * com.joriving.pdf.controller.*.*(..))" +
//            "&& !execution(public * com.joriving.pdf.controller.LoginController.*.*(..))")
    @Pointcut("execution(public * com.joriving.pdf.controller.saaaa*.*.*(..))")
    public void verify() {
    }

    @Before("verify()")
    public void doVerify() {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
//        String role = loginService.getTokenValueFromHeader(request);
//        String joggleName = request.getServletPath();
//        log.info("[URI]: " + joggleName);
        String tokenName = PropertiesUtil.get("projectName") + "-session-token";
        String token = redisTemplate.opsForValue().get(tokenName + "/updateDeliverOrder");
//        String roleStr = null;
        if (token == null ) {
            throw new PdfAuthorizeException(ResultEnum.NO_AUTHORIZE);
        }
        try {
//            if (StringUtils.isEmpty(token)) {
//                roleStr = redisTemplate.opsForValue().get(tokenName + "/updateDeliverOrder");
//            }
            String[] array = token.split(",", -1);
            int index = Arrays.binarySearch(array, "1");
            // role存在于array数组中
            if (index < 0) {
                throw new PdfAuthorizeException(ResultEnum.NO_AUTHORIZE);
            }
        } catch (IllegalArgumentException e) {
            log.error("[redis操作异常]");
            throw new PdfCommonException(ResultEnum.REDIS_COMMON_ERROR);
        }
    }
}
*/
